﻿@model List<Wicresoft.UnifyShow.Business.BusinessCategoryAndSystemModel>
@{
    int pageSize = 4;
    int categoryCount = Model.Count;
    int pageCount = categoryCount % pageSize == 0 ? (categoryCount / pageSize) : (categoryCount / pageSize + 1);
    List<Wicresoft.UnifyShow.Business.BusinessCategoryAndSystemModel> models = Model.OrderByDescending(o => o.BusinessSystemList.Count).ToList();
    List<Wicresoft.UnifyShow.Business.BusinessCategoryAndSystemModel> modelCurrent = new List<Wicresoft.UnifyShow.Business.BusinessCategoryAndSystemModel>();
    int tempLengh = 0;
}
@helper getSystemTD(Wicresoft.UnifyShow.Business.BusinessSystemAndAlertModel mm)
    {
    <td>
        <a href="/BusinessAvailable/Index?businessSystemId=@mm.ID">
            @if (mm.Severity == 2)
            {
                <p class="index_pt_imptant_red ui-icons">
                    <span>@mm.Alias</span></p>
            }
            else if (mm.Severity == 1)
            {
                <p class="index_pt_imptant_yellow ui-icons">
                    <span>@mm.Alias</span></p>
            }
            else
            {
                <p class="index_pt_imptant_green ui-icons">
                    <span>@mm.Alias</span></p>
            }
        </a>
    </td>
}
@for (int num = 0; num < pageCount; num++)
{
    modelCurrent = models.Skip(num * pageSize).Take(pageSize).ToList();
    <div class="index_pt" id="pageCategorysIndex@(num + 1)"  style="display:none;">
        <ul id="slide-items1">
            @foreach (Wicresoft.UnifyShow.Business.BusinessCategoryAndSystemModel categoryAndsystem in modelCurrent)
            {
                tempLengh = categoryAndsystem.BusinessSystemList.Count;
                <li>
                    <div class="index_pt_title ui-icons">
                        <h3>
                            @if (categoryAndsystem.CriticalCount > 0)
                            {
                                <i class="right_title_imptant_red ui-icons">@categoryAndsystem.CriticalCount</i>
                            }
                            else if (categoryAndsystem.WarningCount > 0)
                            {
                                <i class="right_title_imptant_yellow ui-icons">@categoryAndsystem.WarningCount</i>
                            }
                            else
                            { 
                                <i class="right_title_imptant_green ui-icons">@categoryAndsystem.NormalCount</i>
                            }
                            @categoryAndsystem.BusinessCategory.CategoryAlias
                        </h3>
                    </div>
                    <div class="scroll index_pt_bg">
                        <table class="index_pt_imptant" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                @for (int i = 0; i < tempLengh; i++)
                                {
                                    <tr>
                                        @getSystemTD(categoryAndsystem.BusinessSystemList[i])
                                        @if (i < tempLengh - 1)
                                        {
                                            i++;
                                            @getSystemTD(categoryAndsystem.BusinessSystemList[i]);
                                        }
                                    </tr>

                                }
                            </tbody>
                        </table>
                    </div>
                </li>
            }
        </ul>
        <div class="clear">
        </div>
    </div>
}
<div class="slide-controls" id="page">
    @if (pageCount > 1)
    {
        for (int i = 1; i <= pageCount; i++)
        {
        <span class="pageClick" data-page="@i"><a href="#@i" >@i</a></span>
        }
    }
</div>
